<template>
	<view class="container-withdrawal">
		<image src="@/static/imgbgc.png" mode="" style="width: 100%;height: 100%;"></image>
		<scroll-view scroll-y="true" class="app">
			<view class="top-box">
				<view class="rule" @click="$fun.jump(`/pageB/noticeList/noticeInfo?id=19&type=20&name=提现规则`)">
					提现规则
				</view>
				<view class="money-box">
					<view class="money-name">可提现金额</view>
					<view class="money"><text>$</text>{{balance}}</view>
				</view>
				<view class="top">
					<!-- <view class="left">
					<view class="" @click="$fun.jump(`/pageB/noticeList/noticeInfo?id=19&type=20&name=提现规则`)">
						提现规则
					</view>
					<view class="title" style="margin-top: 20rpx;">{{titleName}}</view>
					<view class="num">{{balance}}</view>
				</view>
				<view class="" @click="$fun.jump(`./withdrawList?id=${id}&name=${titleName}`)">
					提现记录
				</view> -->
				</view>
				<!-- <view class="cell nocell" v-if="!isChecked">
				<text class="tit fill" style="color: #232323;">{{placeholder}}</text>
			</view> -->
			</view>


			<view class="cell1">
				<view class="onchargecost">提现金额</view>
				<view class="" style="display: flex;align-items: center;">
					<text style="font-size: 45rpx;">$</text>
					<input class="input" v-model="money" type="text" maxlength="11" placeholder="请输入提现金额"
						placeholder-style="color:#999;font-size:30rpx" />
				</view>

			</view>
			<!-- 	<label class="radio" style="padding: 30rpx;"  @click="isChecked=!isChecked">
			<radio value="1" :checked="isChecked" /><text>开发票</text>
		</label> -->
			<view class="cell nocell">
				<text class="tit fill">选择收款方式</text>
			</view>

			<view class="member">
				<swiper autoplay class="header_slide swiper1" :autoplay="false">
					<swiper-item v-for="(item,index) in list " :key='index'>
						<view :class=" active == index ? 'conter active' : 'conter'" @click="onChange(item,index)">
							<view class="left">
								<view class="cent">{{item.name}}</view>
								<view class="name">{{item.phone}}</view>
							</view>
							<view class="data">{{item.bank}}</view>
						</view>

					</swiper-item>
					<swiper-item v-if="!list.length">
						<view :class=" 'conter'" @click="$fun.jump('/pageA/makemode/makemode',0,0)">
							<view class="left" style="width: 100%;text-align: center;line-height: 90rpx;">
								<view class="cent"></view>
								<view class="name">添加提现方式</view>
							</view>
							<view class="data"></view>
						</view>

					</swiper-item>
				</swiper>
			</view>
			<u-button type="primary" :loading="btnloading" text="提交" color="#1e84f1" shape="circle"
				style="width: 392rpx;" @click="confirm"></u-button>
			<!-- 提现记录 -->
			<view class="records">
				<view class="flex-between header">
					<view class="lt">提现记录</view>
					<view class="rt flex" @click="$fun.jump(`/pageA/wallet/withdrawList?id=${id}&name=提现记录`)">
						<text>查看更多</text>
						<u-icon name="arrow-right" size="14"></u-icon>
					</view>
				</view>
				<view class="content">
					<view class="item" v-for="item in marthlist">
						<view class="flex-between">
							<text style="color: #232323;">提现</text>
							<text class="price">${{item.money}}</text>
						</view>
						<view class="createTime">
							{{$fun.formatTime(item.createtime*1000) }}
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showPwd: false,
				money: '',
				list: [],
				bankList: [],
				bid: '',
				id: '',
				titleName: '', //标题
				placeholder: '',
				active: "`",
				balance: '==',
				balance1: '==',
				withdrawal_type: 0,
				isChecked: false,
				btnloading: false,
				marthlist:[]
			}
		},
		// onNavigationBarButtonTap(e) {
		// 	this.$fun.jump(`/pages/user/wallet/walletdetail?id=${this.id}`)
		// },
		onLoad(options) {
			this.id = options.id
			this.titleName = options.name
			this.bid = options.bid
			this.$fun.ajax.post('index/config', {}).then(res => {
				this.placeholder = res.data.withdrawal_title
				this.withdrawal_type = res.data.withdrawal_type
			})
			this.$fun.ajax.post('config/recharge', {
				id: options.id
			}).then(res => {
				this.balance = res.data.money
				this.balance1 = res.data.withdrawal
			})
			this.getBank()
			this.getList()
		},
		computed: {
			// openExamine() {
			// 	return this.$store.state.openExamine;
			// }
		},
		watch: {
			money(val) {
				if (val) {
					this.money1 = ''
				}
			}
		},
		methods: {
			async getList(){
			const res = await this.$fun.ajax.post('user/withdrawalList', {
				id: this.id,
				page: 1,
				limit: 10
			})
			if(res.code==1){
				this.marthlist = res.data
			}
			
		},
		// 获取银行卡信息
		getBank() {
			this.$fun.ajax.post('user/banklist', {}).then(res => {
				if (res.code == 1) {
					this.bankList = res.data
					let data = res.data
					// for(var i=0;i<data.length;i++){
					this.list = data;
					if (data.length == 0) {
						this.$fun.msg('请先添加提现方式')
						this.$fun.jump('/pageA/makemode/makemode', 0, 1200)
					}
					// }
				}
			})
		},
		onChange(item, index) {
			// //console.log(e)
			this.active = index;
			this.bid = item.id;
		},
		configBank(e) {
			this.bid = this.bankList[e.index].id
		},
		async confirm() {
			if (this.btnloading) return this.$fun.msg('请稍等...')
			let {
				bid,
				id,
				money,
				isChecked
			} = this;
			let parms = {
				bid,
				id,
				money,
				bill: isChecked ? 1 : 0
			}
			if (!money) {
				this.$fun.msg('请输入提现金额')
				return
			}
			if (!bid) {
				this.$fun.msg('请选提现账户')
				return
			}
			this.btnloading = true
			await this.$fun.ajax.post('user/withdrawal', {
				...parms
			}).then(res => {
				if (res.code == 1) {
					this.$fun.msg(res.msg)
					this.$fun.jump('', 4, 1200)
				}
				this.btnloading = false
			}).catch(() => {
				this.btnloading = false
			})
		},
		changePwdState() {
			this.showPwd = !this.showPwd;
		}
	},
	onNavigationBarButtonTap(e) {
		const index = e.index;
		// #ifdef APP-PLUS
		const pages = getCurrentPages();
		const page = pages[pages.length - 1];
		const currentWebview = page.$getAppWebview();
		currentWebview.hideTitleNViewButtonRedDot({
			index
		});
		// #endif
		uni.navigateTo({
			url: `./withdrawList?id=${this.id}&name=${this.titleName}`
		})
	}

	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;
	}

	.container-withdrawal {
		height: 100%;
		position: relative;

		.records {
			margin: 20rpx 0;

			.header {
				.lt {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #232323;
					border-left: 5rpx solid #1e84f1;
					padding-left: 10rpx;
				}

				.rt {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
				}
			}

			.content {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #232323;
				line-height: 28rpx;

				.item {
					border-bottom: 1rpx solid #dedede;
					padding: 5px 0;
				}

				.price {
					font-family: DIN, DIN;
					font-weight: bold;
					font-size: 24rpx;
					color: #232323;
				}

				.createTime {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					line-height: 32rpx;
				}
			}
		}
	}

	.app {
		position: absolute;
		top: 50rpx;
		left: 50%;
		transform: translate(-50%);
		background-color: #fff;
		padding: 10rpx 30rpx 30rpx;
		border-radius: 20rpx;
		height: 85%;
		width: 95%;

		.add-btn {
			margin: 0 30rpx;
		}

		// padding: 20rpx;
		.top-box {
			color: #232323;
			padding: 20rpx 20rpx 50rpx;

			.rule {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #232323;
				text-align: end;
			}

			.money-box {
				text-align: center;

				.money-name {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #232323;
				}

				.money {
					font-family: DIN, DIN;
					font-weight: bold;
					font-size: 64rpx;
					color: #232323;

					text {
						font-size: 40rpx;
					}
				}
			}
		}

		/* 头部 */
		.top {
			display: flex;
			justify-content: space-between;

			.left {
				// margin-top: 40rpx;

				.title {
					font-size: 24rpx;
					color: #232323;
				}

				.num {
					font-size: 48rpx;
					color: #232323;
					margin-top: 30rpx;
					font-weight: bold;
				}

				.jyjl {
					font-size: 24rpx;
					color: #dd1021;
					margin-top: 50rpx;
				}
			}

			.rightimg {
				width: 233rpx;
				height: 240rpx;
				margin-right: 50rpx;
			}
		}

		/* 内容区 */
		.conter {
			.title {
				color: #666;
				margin-top: 50rpx;
				font-size: 30rpx;
			}

			.cent {
				margin-top: 25rpx;
				overflow: hidden;

				.list {
					width: 200rpx;
					height: 120rpx;
					border: 1rpx solid #e8e8e8;
					float: left;
					margin-right: 39rpx;
					margin-bottom: 45rpx;
					position: relative;
					text-align: center;
					line-height: 120rpx;
					border-radius: 15rpx;

					&:nth-child(3n) {
						margin-right: 0;
					}

					input {
						height: 50rpx;
						margin-left: 10rpx;
						margin-top: 35rpx;
					}

					.van-cell {
						padding: 0;
						width: 180rpx;
					}

					image {
						width: 40rpx;
						height: 37rpx;
						position: absolute;
						bottom: 0;
						right: 0;
						display: none;
					}

					&.active {
						color: #dd1021;
						border: 1rpx solid #dd1021;

						image {
							display: block;
						}
					}
				}
			}
		}

		.bottom {
			width: 690rpx;

			.text {
				margin-bottom: 30rpx;
				display: flex;
				font-size: 24rpx;
				line-height: 40rpx;

				.van-checkbox {}

				navigator {
					color: #dd1021;
				}
			}

			button {
				width: 690rpx;
				height: 78rpx;
				line-height: 78rpx;
				background: #dd1021;
				color: #fff;
				border-radius: 78rpx;
				font-weight: 500;
				margin: 0;
				padding: 0;
			}
		}
	}

	/* 提现 */
	.member {
		.conter {
			width: 694rpx;
			height: 175rpx;
			background: #f3f3f3;
			margin: 20rpx auto;
			border-radius: 10rpx;
			display: flex;

			&.active {
				border: 1px solid #1E84F1;
			}

			.left {
				margin-left: 20rpx;
				margin-top: 25rpx;
				width: 425rpx;

				.top {
					width: 82rpx;
					height: 30rpx;
					font-size: 18rpx;
					color: #fff;
					background: linear-gradient(to right, #242a42, #474e61);
					border-radius: 30rpx;

					image {
						width: 20rpx;
						height: 17rpx;
						margin-left: 10rpx;
						margin-right: 5rpx
					}
				}

				.cent {
					color: #333;
					font-size: 32rpx;
					margin-top: 10rpx;

					text {
						color: #1E84F1;
					}
				}

				.name {
					margin-top: 15rpx;
					font-size: 24rpx;
					color: #666;
				}
			}

			.data {
				margin-top: 65rpx;
				color: #000;
				font-size: 28rpx;
				margin-right: 20rpx;
			}

			.van-checkbox {
				margin-top: 65rpx;
			}
		}
	}



	.nocell {
		border-bottom: none !important;
	}

	.cell1 {
		min-height: 110rpx;
		margin: 0 40rpx;
		padding: 10rpx 0;
		border-bottom: 1px solid rgb(236, 236, 236);

		.onchargecost {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #232323;
			line-height: 100rpx;
		}
	}

	.cell {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		margin: 0 40rpx;
		border-bottom: 1px solid rgb(236, 236, 236);

		&:first-child {
			margin-bottom: 10rpx;
		}

		&:after {
			left: 40rpx;
			right: 40rpx;
			border-color: #d8d8d8;
		}

		.tit {
			font-size: 30rpx;
			color: #333;
		}

		.avatar-wrap {
			width: 120rpx;
			height: 120rpx;
			position: relative;
			border-radius: 100rpx;
			overflow: hidden;

			.avatar {
				width: 100%;
				height: 100%;
				border-radius: 100rpx;
			}

			.progress {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				width: 100rpx;
				height: 100rpx;
				box-shadow: rgba(0, 0, 0, .6) 0px 0px 0px 2005px;
				border-radius: 100rpx;
				transition: .5s;
				opacity: 0;

				&.no-transtion {
					transition: 0s;
				}

				&.show {
					opacity: 1;
				}
			}
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}

		switch {
			margin: 0;
			transform: scale(0.8) translateX(10rpx);
			transform-origin: center right;
		}

		.tip {
			margin-left: 20rpx;
			font-size: 28rpx;
			color: #999;
		}

		.checkbox {
			padding: 12rpx 0 12rpx 40rpx;
			font-size: 28rpx;
			color: #333;

			.mix-icon {
				margin-right: 12rpx;
				font-size: 36rpx;
				color: #ccc;
			}

			.icon-xuanzhong {
				color: $base-color;
			}
		}
	}
</style>